/*
* @Author: hj
* @Date:   2018-04-15 22:28:18
* @Last Modified by:   Aantabile
* @Last Modified time: 2018-04-19 23:15:06
*/
const path = require('path');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ExtractTextPlugin = require("extract-text-webpack-plugin");

module.exports = {
	entry: {
		app: './src/app.js'
	},
	output: {
		filename: 'js/[name].[hash].js',
		path: path.resolve(__dirname, 'dist'),
	},
	plugins: [
		new CleanWebpackPlugin(['dist']),
		new HtmlWebpackPlugin({
			title: 'Production'
		}),
		new ExtractTextPlugin("css/[name].css"),

	],
	module: {
	    rules: [
	     {
		      test:/\.(js|jsx)$/,
		      loader: "babel-loader",
		      exclude:/node_modules/
	      },
	      {
	        test: /\.css$/,
	        use: ExtractTextPlugin.extract({
	          fallback: "style-loader",
	          use: "css-loader"
	        })
	      },
	      {
	        test: /\.(png|svg|jpg|gif)$/,
	        use: [
	          'file-loader'
	        ]
	      },
	      {
	        test: /\.html$/,
	        loader: 'html-loader'
	      },
	      {
	        test: /\.(woff|woff2|eot|ttf|otf)$/,
	        use: [
	          'file-loader'
	        ]
	      },
	      {
	        test: /\.(csv|tsv)$/,
	        use: [
	          'csv-loader'
	        ]
	      },
	      {
	        test: /\.xml$/,
	        use: [
	          'xml-loader'
	        ]
	      }
	    ]
  }
}